package serach;

public class BM22 {
    public int compare (String version1, String version2) {
        // write code here
        int len1 = version1.length();
        int len2 = version2.length();
        int i=0,j=0;

        while (i<len1||j<len2)
        {
            long num1=0;
            long num2 =0;
            while (version1.charAt(i)!='.'&&i<len1)
            {
                num1 = num1*10+version1.charAt(i)-'0';
                i++;
            }
            while (version2.charAt(j)!='.'&&j<len2)
            {
                num2 = num2*10+version2.charAt(j)-'0';
                j++;
            }
            if(num1>num2)
            {
                return 1;
            }
            if(num1<num2)
            {return -1;}
            i++;
            j++;

        }
        return 0;
    }
}
